package com.yunhe.inspect.client.fallback;

import com.yunhe.common.exception.ArgumentErrorException;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.authority.Organization;
import com.yunhe.common.model.authority.User;
import com.yunhe.common.model.inspect.RealStationOfficeCompanyVo;
import com.yunhe.common.util.FallbackUtil;
import com.yunhe.inspect.client.AuthorityClient;
import feign.hystrix.FallbackFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * @ClassName AuthorityClientFallbackFactory
 * @Description TODO
 * @Author HeTao
 * @Date 2021/11/9 16:22
 * @Version 1.0
 **/
public class AuthorityClientFallbackFactory  implements FallbackFactory<AuthorityClient> {
    @Override
    public AuthorityClient create(Throwable cause) {
        return new AuthorityClient() {

            @RequestMapping(value = "/organization/getSubOrgByLoginUser", method = RequestMethod.GET)
            @Override
            public ResponseEntity<ResultObject<List<Organization>>> getSubOrgByLoginUser(Long stationId, Long userId, Boolean childFlag) throws ArgumentErrorException {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<List<Organization>>> searchOrgByStationId(Long stationId, Long firmId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<List<RealStationOfficeCompanyVo>>> searchStationAndOfficeAndCompanyByStationId(Long stationId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<List<RealStationOfficeCompanyVo>>> searchStationAndOfficeAndCompany(List<String> value) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<User>> getUserById(Long id) {
                return FallbackUtil.getDefaultFallBack();
            }
        };
    }
}
